/**
 * 
 */

//初始化加载
$(function(){
	getSubset();
	getChild();
});

$("#btn_search").click(function(){
	mui('.mui-popover').popover('toggle');
	$(".mui-backdrop.mui-active").hide();
	$("#serch").hide();
});

function tree(orgCode){
	location.href="tree?memberCode="+memberCode+"&orgCode="+orgCode;
}

//加载部门成员
function getSubset(){
	var month = $("#month1").val();
	var year = $("#year1").val();
	var quarter = $("#quarter1").val();
	$.ajax({
		url : "../com/subset",
		type : "post",
		dataType : "json",
		data : {"orgCode":orgCode,"memberCode":memberCode,"month":month,"year":year,"quarter":quarter},
		success : function(data){
			
			console.log(data);
			
			$("#msg").html(orgName);
			
			if(data == null || data.length == 0){
				$("#list").html("<div style='text-align:center;'>暂无信息</div>");
				return;
			}
			
			$("#list").html("");
			var str = "";  
			$.each(data,function(n,value) {
        		str += '<tr style="height:40px;">';
        		str += '<td style="width:25%;"><a href="member?emplCode='+value.PERSON_LIABLE_CODE+'&memberCode='+memberCode+'&orgCode='+orgCode+'">'+value.PERSON_LIABLE_NAME+'</a></td>';
        		str += '<td style="width:42%;"><a href="member?emplCode='+value.PERSON_LIABLE_CODE+'&memberCode='+memberCode+'&orgCode='+orgCode+'">'+value.POST_ZH_SNAME+'</a></td>';
        		str += '<td style="width:33%;"><a href="member?emplCode='+value.PERSON_LIABLE_CODE+'&memberCode='+memberCode+'&orgCode='+orgCode+'">'+value.POSTSEQ_NAME+'</a></td>';
        		str += '</tr>';
			});  
			
			$("#list").html(str);
		}
	});
}

function getChild(){
	
	$.ajax({
		url : "../com/child",
		type : "post",
		dataType : "json",
		data : {"orgCode":orgCode},
		success : function(data){
			
			console.log(data);
			
			if(data == null || data.length == 0){
				$("#child").html("<p>暂无信息</p>");
				return;
			}
			
			$("#child").html("");
			var str = "";  
			$.each(data,function(n,value) {
				str += '<ul>';
				str += '<li class="mui-table-view-cell ">';
				str += '<a class=""  style="text-align:left;padding-left: 0px;" href="tree?memberCode='+memberCode+'&orgCode='+value.ORG_CODE+'">'+value.ORG_ZH_SNAME+'</a>';
				str += ' </li>';
				str += '</ul>';
			});   
			$("#child").html(str);
		}
	});
	
}